theme_clean()
}
PlotVarProp_distrust_doct <- function(data, xvar){
data %>%
group_by_(xvar) %>%
dplyr::summarize(Prop.P36_generaldistrust_doct = mean(P36_generaldistrust_doct == "Distrusts", na.rm = T),
SD.P36_generaldistrust_doct = sqrt(Prop.P36_generaldistrust_doct*(1-Prop.P36_generaldistrust_doct)/n())
) %>%
gather(key = "key", value = "value", -xvar) %>%
separate(key, into = c("Statistic", "Variable"), sep = "[.]") %>%
spread(Statistic, value) %>%
ggplot(aes_string(x = xvar, y = "Prop"))+
geom_point(position = position_dodge(width = 0.5))+
geom_errorbar(aes(ymin=Prop-2*SD, ymax=Prop+2*SD),position = position_dodge(width = 0.5), width=.2)+
ggtitle(xvar)+
facet_wrap(~Variable)+
labs(x="")+
theme_clean()
}
# Main DV. Before or after the experiment? Before
Prev <- c("P42_Stayhome", "P46_TrueAndProb_chloroquine", "P44_TrueAndProb_ivermectin")
SocioDem <- "+ sex+ age_Group + income + interior + P1_race_NonWhite + P2_educ + P3_religion_Pentecostal"
Health_Polit <- "+ P5_support_Bolsonaro + P11_Negative_Politicians + P17_covid_fear + P18_covid_serious + P31_distrust_pol + P37_earlytreat_Positive + P40_info_veryfreq + P41_noneOnly"
#Predictors of Prev (main DV)
MainDVDemog <- map(Prev, ~ModelDummyTreatment(Data, .x, SocioDem))
MainDVHealthPol <- map(Prev, ~ModelDummyTreatment(Data, .x, Health_Polit))
MainDVHealthPol_Demog <- map(Prev, ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
tab_model(MainDVDemog[[1]],MainDVDemog[[2]],MainDVDemog[[3]])
tab_model(MainDVHealthPol[[1]],MainDVHealthPol[[2]],MainDVHealthPol[[3]])
tab_model(MainDVHealthPol_Demog[[1]],MainDVHealthPol_Demog[[2]],MainDVHealthPol_Demog[[3]])
#pref_drug, covidemed_use, vaccine_hesitance
OtherDV <- c("P14_drug_pref_serious", "P15_drug_pref_worsening", "P28_covidmed_use")
OtherDVDemog <- map(OtherDV, ~ModelDummyTreatment(Data, .x, SocioDem))
OtherDVHealthPol <- map(OtherDV, ~ModelDummyTreatment(Data, .x, Health_Polit))
OtherDVHealthPol_Demog <- map(OtherDV, ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
tab_model(OtherDVDemog[[1]],OtherDVDemog[[2]],OtherDVDemog[[3]])
tab_model(OtherDVHealthPol[[1]],OtherDVHealthPol[[2]],OtherDVHealthPol[[3]])
tab_model(OtherDVHealthPol_Demog[[1]],OtherDVHealthPol_Demog[[2]],OtherDVHealthPol_Demog[[3]])
#Regressions for Ordinal Kit Covid
KitCovidDemog <- map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, SocioDem))
KitCovidDemogHealthPol <- map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, Health_Polit))
KitCovidHealthPol_Demog  <-map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, SocioDem, Health_Polit))
tab_model(KitCovidDemog)
tab_model(KitCovidDemogHealthPol)
tab_model(KitCovidHealthPol_Demog)
#Ordinal Index variable for drug preference questions
OrdinalDrugIndexDemog <- map("as.factor(Drug_Preference_Index)", ~ModelLikertTreatment(Data, .x, SocioDem))
OrdinalDrugIndexDemogHealthPol <- map("as.factor(Drug_Preference_Index)", ~ModelLikertTreatment(Data, .x, Health_Polit))
OrdinalDrugIndexHealthPol_Demog  <-map("as.factor(Drug_Preference_Index)", ~ModelLikertTreatment(Data, .x, SocioDem, Health_Polit))
tab_model(OrdinalDrugIndexDemog)
tab_model(OrdinalDrugIndexDemogHealthPol)
tab_model(OrdinalDrugIndexHealthPol_Demog)
#and P30
SelfMedDemog <- map("P30_covid_selfmed", ~ModelDummyTreatment(Data, .x, SocioDem))
SelfMedDemogHealthPol <- map("P30_covid_selfmed", ~ModelDummyTreatment(Data, .x, Health_Polit))
SelfMedHealthPol_Demog  <-map("P30_covid_selfmed", ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
tab_model(SelfMedDemog)
tab_model(SelfMedDemogHealthPol)
tab_model(SelfMedHealthPol_Demog)
#Plot proportion
SocioDem2 <- c("sex", "age_Group","income","interior", "P1_race_NonWhite", "P2_educ", "P3_religion_Pentecostal")
Health_Polit2 <-c("P5_support_Bolsonaro", "P11_Negative_Politicians", "P17_covid_fear","P18_covid_serious",
"P31_distrust_pol", "P37_earlytreat_Positive", "P40_info_veryfreq", "P41_noneOnly")
Data <- Data %>%
mutate(P5_support_Bolsonaro = fct_relevel(P5_support_Bolsonaro, "No", "Maybe", "Yes"))
PlotDVProp(Data, "P5_support_Bolsonaro")
PlotDVProp(Data, "P5_support_Bolsonaro")
DVbyDemo <- map(SocioDem2, ~PlotDVProp(data=Data,.x))
DVbyHealth_Pol<- map(Health_Polit2, ~PlotDVProp(data=Data,.x))
MedUsebyDemo <- map(SocioDem2, ~PlotVarProp_MedUse(data=Data,.x))
MedUsebyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_MedUse(data=Data,.x))
selfmedbyDemo <- map(SocioDem2, ~PlotVarProp_selfmed(data=Data,.x))
selfmedbyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_selfmed(data=Data,.x))
vaccine_hesitancebyDemo <- map(SocioDem2, ~PlotVarProp_vaccine_hesitance(data=Data,.x))
vaccine_hesitancebyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_vaccine_hesitance(data=Data,.x))
pref_seriousbyDemo <- map(SocioDem2, ~PlotVarProp_pref_serious(data=Data,.x))
pref_seriousbyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_pref_serious(data=Data,.x))
pref_worseningbyDemo <- map(SocioDem2, ~PlotVarProp_treat_pref_worsening(data=Data,.x))
pref_worseningbyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_treat_pref_worsening(data=Data,.x))
treatpref_doctorbyDemo <- map(SocioDem2, ~PlotVarProp_treatpref_doctor(data=Data,.x))
treatpref_doctorbyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_treatpref_doctor(data=Data,.x))
distrust_doctbyDemo <- map(SocioDem2, ~PlotVarProp_distrust_doct(data=Data,.x))
distrust_doctbyHealth_Pol<- map(Health_Polit2, ~PlotVarProp_distrust_doct(data=Data,.x))
pref_seriousbyHealth_Pol
pref_seriousbyDemo
vaccine_hesitancebyHealth_Pol
pref_worseningbyDemo
pref_worseningbyHealth_Pol
treatpref_doctorbyDemo
treatpref_doctorbyHealth_Pol
distrust_doctbyDemo
distrust_doctbyHealth_Pol
DVbyDemo
DVbyHealth_Pol
MedUsebyDemo
MedUsebyHealth_Pol
selfmedbyDemo
selfmedbyHealth_Pol
vaccine_hesitancebyDemo
vaccine_hesitancebyHealth_Pol
#Correlations
#Main DV correlations
p.mat <- Data %>%
dplyr::select("P42_Stayhome", "P46_TrueAndProb_chloroquine", "P44_TrueAndProb_ivermectin","P47_kitcovid") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor_pmat()
Data %>%
dplyr::select("P42_Stayhome", "P46_TrueAndProb_chloroquine", "P44_TrueAndProb_ivermectin","P47_kitcovid") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor() %>%
round(1) %>%
ggcorrplot(hc.order = TRUE,
ggtheme = ggplot2::theme_classic,
type = "lower",
p.mat = p.mat,
lab = TRUE)
# + annotate("text", x = 2.5, y = 5, label = "X means non-significant\ncorrelation (95%)")
# IV of interest
p.mat <- Data %>%
dplyr::select("sex", "age_Group","income","interior", "P1_race_NonWhite", "P2_educ", "P3_religion_Pentecostal",
"P5_support_Bolsonaro", "P11_Negative_Politicians", "P17_covid_fear","P18_covid_serious",
"P31_distrust_pol", "P37_earlytreat_Positive", "P40_info_veryfreq", "P41_noneOnly") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor_pmat()
Data %>%
dplyr::select("sex", "age_Group","income","interior", "P1_race_NonWhite", "P2_educ", "P3_religion_Pentecostal",
"P5_support_Bolsonaro", "P11_Negative_Politicians", "P17_covid_fear","P18_covid_serious",
"P31_distrust_pol", "P37_earlytreat_Positive", "P40_info_veryfreq", "P41_noneOnly") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor() %>%
round(1) %>%
ggcorrplot(hc.order = TRUE,
ggtheme = ggplot2::theme_classic,
type = "lower",
p.mat = p.mat,
lab = TRUE)+
annotate("text", x = 6, y = 13, label = "X means non-significant\ncorrelation (95%)")
#Everything
p.mat <- Data %>%
dplyr::select("P42_Stayhome", "P46_TrueAndProb_chloroquine", "P44_TrueAndProb_ivermectin","P47_kitcovid",
"P14_treat_pref_serious_Ordinal","treat_pref_worsening_Ordinal" ,"sex", "age_Group","income","interior", "P1_race_NonWhite", "P2_educ",
"P3_religion_Pentecostal","P5_support_Bolsonaro", "P11_Negative_Politicians", "P17_covid_fear","P18_covid_serious",
"P31_distrust_pol", "P37_earlytreat_Positive", "P40_info_veryfreq", "P41_noneOnly") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor_pmat()
Data %>%
dplyr::select("P42_Stayhome", "P46_TrueAndProb_chloroquine", "P44_TrueAndProb_ivermectin","P47_kitcovid",
"P14_treat_pref_serious_Ordinal","treat_pref_worsening_Ordinal" ,"sex", "age_Group","income","interior", "P1_race_NonWhite", "P2_educ",
"P3_religion_Pentecostal","P5_support_Bolsonaro", "P11_Negative_Politicians", "P17_covid_fear","P18_covid_serious",
"P31_distrust_pol", "P37_earlytreat_Positive", "P40_info_veryfreq", "P41_noneOnly") %>%
mutate_if(is.factor, as.numeric) %>%
na.exclude() %>%
cor() %>%
round(1) %>%
ggcorrplot(hc.order = TRUE,
ggtheme = ggplot2::theme_classic,
type = "lower",
p.mat = p.mat,
lab = TRUE)+
annotate("text", x = 6, y = 13, label = "X means non-significant\ncorrelation (95%)")
#Plotting regression models
#Main DV
Data <- Data %>%
mutate(belief_misinformation =  (P44_TrueAndProb_ivermectin=="True or Probably True" | P46_TrueAndProb_chloroquine == "True or Probably True") %>%
as.numeric())
Prev <- c("P42_Stayhome", "belief_misinformation", "P28_covidmed_use")
SocioDem <- "+ sex+ age_Group + income + interior + P1_race_NonWhite + P2_educ + P3_religion_Pentecostal"
Health_Polit <- "+ treat_pref_worsening_Ordinal + P5_support_Bolsonaro + P17_covid_fear + P37_earlytreat_Positive + P40_info_veryfreq"
#Predictors of Prev (main DV)
MainDVHealthPol_Demog2 <- map(Prev, ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
#Regressions for Ordinal Kit Covid
KitCovidHealthPol_Demog2  <-map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, SocioDem, Health_Polit))
#Plots
Model_StayHome<-broom::tidy(MainDVHealthPol_Demog2[[1]]) %>%
mutate(Variable = "Stay Home") %>%
dplyr::select(-"p.value", SD="std.error")
Model_belief_misinformation <- broom::tidy(MainDVHealthPol_Demog2[[2]])%>%
mutate(Variable = "Belief in misinformation") %>%
dplyr::select(-"p.value", SD="std.error")
Model_Covidmed_use <- broom::tidy(MainDVHealthPol_Demog2[[3]])%>%
mutate(Variable = "Covidmed Use") %>%
dplyr::select(-"p.value", SD="std.error")
Model_KitCovid <- broom::tidy(KitCovidHealthPol_Demog2[[1]])%>%
mutate(Variable = "Kit Covid") %>%
dplyr::select(-"coef.type", SD="std.error")
Models_MainDV<-rbind(Model_StayHome,Model_belief_misinformation,
Model_Covidmed_use, Model_KitCovid)
P_Models_MainDV<-filter(Models_MainDV, !(term %in% c("(Intercept)", "-1|0", "0|1"))) %>%
ggplot(aes(y=term, x=estimate )) +
geom_errorbar(aes(xmin=estimate-2*SD, xmax=estimate+ 2*SD), width=.2) +
geom_point(shape=19, size=1.5) +
geom_vline(xintercept=0, linetype="dashed",
size=1, color="grey", alpha=0.5)+
theme_bw()+
ggtitle("Models for Main Misinformation Variables (logistic coefficients)") +
labs(color = "Variable") +
theme(plot.title = element_text(hjust = 0.5, face = "plain")) +
xlab("") + ylab("")+
#  coord_flip(ylim = c(-2, 3))+
facet_grid(cols = vars(Variable))
#+
#    scale_y_discrete(labels = c("Drug Preference",  "Women", "Bolsonaro Loyalist",
#                                "Bolsonaro Eventual Supporter", "Very Frequently Informed",
#                                "Positive Early Treatment","Pentecostal",
#                                "Education", "Covid Fear", "White", "Interior", "Income", "Age"))
P_Models_MainDV
#Main DV with more IV
#Trrademedia as 8,9,10
Data <- Data %>%
mutate(
P31_trust_pol = fct_collapse(as.factor(P31_trust_pol_cat),
"Trusts"  = c("4","5"), "Does Not Trusts"  = c("1","2","3")),
P32_trust_cientists = fct_collapse(as.factor(P32_trust_cientists_cat),
"Trusts"  = c("4","5"), "Does Not Trusts"  = c("1","2","3")),
P33_trust_ANVISA = fct_collapse(as.factor(P33_trust_ANVISA_cat),
"Trusts"  = c("4","5"), "Does Not Trusts"  = c("1","2","3")),
P34_trust_press = fct_collapse(as.factor(P34_trust_press_cat),
"Trusts"  = c("4","5"), "Does Not Trusts"  = c("1","2","3"))
)
Data <- Data %>%
mutate(belief_misinformation =  (P44_TrueAndProb_ivermectin=="True or Probably True" | P46_TrueAndProb_chloroquine == "True or Probably True") %>%
as.numeric())
Prev <- c("P42_Stayhome", "belief_misinformation", "P28_covidmed_use")
SocioDem <- "+ sex+ age_Group + income + interior + P1_race_NonWhite + P2_educ + P3_religion_Pentecostal"
Health_Polit <- "+ treat_pref_worsening_Ordinal + P5_support_Bolsonaro +
P17_covid_fear + P37_earlytreat_Positive +  P31_trust_pol + P32_trust_cientists + P33_trust_ANVISA +
P34_trust_press + P41_socmedOnly + P41_tradmediaOnly + P41_PeopleOnly"
#Predictors of Prev (main DV)
MainDVHealthPol_Demog2 <- map(Prev, ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
#Regressions for Ordinal Kit Covid
KitCovidHealthPol_Demog2  <-map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, SocioDem, Health_Polit))
#Plots
Model_StayHome<-broom::tidy(MainDVHealthPol_Demog2[[1]]) %>%
mutate(Variable = "Stay Home") %>%
dplyr::select(-"p.value", SD="std.error")
Model_belief_misinformation <- broom::tidy(MainDVHealthPol_Demog2[[2]])%>%
mutate(Variable = "Belief in misinformation") %>%
dplyr::select(-"p.value", SD="std.error")
Model_Covidmed_use <- broom::tidy(MainDVHealthPol_Demog2[[3]])%>%
mutate(Variable = "Covidmed Use") %>%
dplyr::select(-"p.value", SD="std.error")
Model_KitCovid <- broom::tidy(KitCovidHealthPol_Demog2[[1]])%>%
mutate(Variable = "Kit Covid") %>%
dplyr::select(-"coef.type", SD="std.error")
Models_MainDV<-rbind(Model_StayHome,Model_belief_misinformation,
Model_Covidmed_use, Model_KitCovid)
P_Models_MainDVPlus<-filter(Models_MainDV, !(term %in% c("(Intercept)", "-1|0", "0|1"))) %>%
ggplot(aes(y=fct_reorder(term, estimate, .desc = TRUE), x=estimate )) +
geom_errorbar(aes(xmin=estimate-2*SD, xmax=estimate+ 2*SD), width=.2) +
geom_point(shape=19, size=1.5) +
geom_vline(xintercept=0, linetype="dashed",
size=1, color="grey", alpha=0.5)+
theme_bw()+
ggtitle("Models for Main Misinformation Variables (logistic coefficients)") +
labs(color = "Variable") +
theme(plot.title = element_text(hjust = 0.5, face = "plain")) +
xlab("") + ylab("")+
#  coord_flip(ylim = c(-2, 3))+
facet_grid(cols = vars(Variable))
#+
#  scale_y_discrete(labels = c("Drug Preference",  "Women", "Bolsonaro Loyalist",
#                              "Bolsonaro Eventual Supporter", "Very Frequently Informed",
#                              "Positive Early Treatment","Pentecostal",
#                              "Education", "Covid Fear", "White", "Interior", "Income", "Age"))
P_Models_MainDVPlus
#Drop P40 freq of information. Include social media not only and people not only. ANVISA trust check coding
#Plot multivariate and univariate versiones of full regressions with labels. Order by value of coeffcient
#Right down the relative sizes (coefficients for the significant ones and drug preference)
Prev <- c("P42_Stayhome", "belief_misinformation", "P28_covidmed_use")
SocioDem <- "+ sex+ age_Group + income + interior + P1_race_NonWhite + P2_educ + P3_religion_Pentecostal"
Health_Polit <- "+ treat_pref_worsening_Ordinal + P5_support_Bolsonaro +
P17_covid_fear + P37_earlytreat_Positive +  P31_trust_pol + P32_trust_cientists + P33_trust_ANVISA +
P34_trust_press + P41_socmed + P41_tradmediaOnly + P41_People"
#Predictors of Prev (main DV)
MainDVHealthPol_Demog2 <- map(Prev, ~ModelDummyTreatment(Data, .x, SocioDem, Health_Polit))
#Regressions for Ordinal Kit Covid
KitCovidHealthPol_Demog2  <-map("as.factor(P47_kitcovid)", ~ModelLikertTreatment(Data, .x, SocioDem, Health_Polit))
#Plots
Model_StayHome<-broom::tidy(MainDVHealthPol_Demog2[[1]]) %>%
mutate(Variable = "Stay Home") %>%
dplyr::select(-"p.value", SD="std.error")
Model_belief_misinformation <- broom::tidy(MainDVHealthPol_Demog2[[2]])%>%
mutate(Variable = "Belief in misinformation") %>%
dplyr::select(-"p.value", SD="std.error")
Model_Covidmed_use <- broom::tidy(MainDVHealthPol_Demog2[[3]])%>%
mutate(Variable = "Covidmed Use") %>%
dplyr::select(-"p.value", SD="std.error")
Model_KitCovid <- broom::tidy(KitCovidHealthPol_Demog2[[1]])%>%
mutate(Variable = "Kit Covid") %>%
dplyr::select(-"coef.type", SD="std.error")
Models_MainDV<-rbind(Model_StayHome,Model_belief_misinformation,
Model_Covidmed_use, Model_KitCovid)
Models_MainDV<- Models_MainDV %>%
mutate(
term = recode(as.factor(term), P5_support_BolsonaroYes = "Bolsonaro Loyalist", P5_support_BolsonaroMaybe = "Bolsonaro Eventual Supporter", "P3_religion_PentecostalPentecostal" ="Pentecostal",
P31_trust_polTrusts = "Trust Politicians","P41_PeopleIncludes People" = "Informed by People",P37_earlytreat_PositivePositive = "Positive View on Early Treatment",
"interiorInterior of the state" = "Interior",treat_pref_worsening_Ordinal = "Drug Preference","P41_socmedUses Social Media" = "Informed by Social Media",age_Group = "Age",
income = "Income", P1_race_NonWhiteWhite = "White","P41_tradmediaOnlyTrade Media Only" = "Informed Only by Trade Media",P33_trust_ANVISATrusts = "Trust ANVISA",
P2_educ =  "Education", sexWomen = "Women",P17_covid_fear = "Covid Fear",P34_trust_pressTrusts = "Trust Press",P32_trust_cientistsTrusts = "Trust Scientists")
)
P_Models_MainDVPlus2<-filter(Models_MainDV, !(term %in% c("(Intercept)", "-1|0", "0|1"))) %>%
ggplot(aes(y=fct_reorder(term, estimate, .desc = TRUE), x=exp(estimate) )) +
geom_errorbar(aes(xmin=exp(estimate-2*SD), xmax=exp(estimate+ 2*SD)), width=.2) +
geom_point(shape=19, size=1.5) +
geom_vline(xintercept=1, linetype="dashed",
size=1, color="grey", alpha=0.5)+
theme_bw()+
ggtitle("Models for Main Misinformation Variables (Odds Ratio)") +
labs(color = "Variable") +
theme(plot.title = element_text(hjust = 0.5, face = "plain")) +
xlab("") + ylab("")+
#  coord_flip(ylim = c(-2, 3))+
facet_grid(cols = vars(Variable))
#+
#  scale_y_discrete(labels = c("Bolsonaro Loyalist", "Bolsonaro Eventual Supporter", "Trust Politicians",
#                              "Positive View on Early Treatment", "Informed by People", "Trust ANVISA",
#                              "Pentecostal","Informed by Social Media", "Interior", "Age", "Drug Preference",
#                              "Informed Only by Trade Media", "Women", "Income", "Education", "Covid Fear",
#                              "White", "Trust Press", "Trust Scientists"
#                              ))
P_Models_MainDVPlus2
#One at a time
One_At_A_Time <- function(vardep, varind,data){
model<- glm(paste0(vardep, "~ ", varind), data = data, family = binomial)
M<-data.frame(coef(summary(model))[2,1])
M[1,2]<-data.frame(coef(summary(model))[2,2])
rownames(M)[1]<-varind
colnames(M)[1]<-"Value"
colnames(M)[2]<-"Std. Error"
return(M)
}
One_At_A_Time2 <- function(vardep, varind,data){
model<- polr(paste0(vardep, "~ ", varind), data = data, Hess=TRUE)
M<-data.frame(coef(summary(model))[1,1])
M[1,2]<-data.frame(coef(summary(model))[1,2])
rownames(M)[1]<-varind
colnames(M)[1]<-"Value"
colnames(M)[2]<-"Std. Error"
return(M)
}
OneAtTime<-data.frame(matrix(NA, 18,2))
rownames(OneAtTime)<-c("sex", "age_Group" , "income" , "interior" , "P1_race_NonWhite" , "P2_educ" ," P3_religion_Pentecostal",
"treat_pref_worsening_Ordinal", "P5_support_Bolsonaro",
"P17_covid_fear",  "P37_earlytreat_Positive",   "P31_trust_pol",  "P32_trust_cientists",  "P33_trust_ANVISA",
"P34_trust_press",  "P41_socmed", "P41_tradmediaOnly", "P41_People")
for (i in rownames(OneAtTime)){
OneAtTime[i,1:2]<-  One_At_A_Time("P42_Stayhome",i,Data)
}
colnames(OneAtTime)[c(1,2)]<-c("Estimate","SD")
OneAtTimeP42_Stayhome<- OneAtTime %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Stay Home")
model<- glm("P42_Stayhome ~ P5_support_Bolsonaro", data = Data, family = binomial)
M<-data.frame(coef(summary(model))[3,1])
M[1,2]<-data.frame(coef(summary(model))[3,2])
rownames(M)[1]<-"P5_support_Bolsonaro2"
colnames(M)[1]<-"Estimate"
colnames(M)[2]<-"SD"
M <- M %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Stay Home")
OneAtTimeP42_Stayhome<- rbind(OneAtTimeP42_Stayhome,M)
for (i in rownames(OneAtTime)){
OneAtTime[i,1:2]<-  One_At_A_Time("belief_misinformation",i,Data)
}
colnames(OneAtTime)[c(1,2)]<-c("Estimate","SD")
OneAtTime_belief_misinformation<- OneAtTime %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Belief in Misinformation")
model<- glm("belief_misinformation ~ P5_support_Bolsonaro", data = Data, family = binomial)
M<-data.frame(coef(summary(model))[3,1])
M[1,2]<-data.frame(coef(summary(model))[3,2])
rownames(M)[1]<-"P5_support_Bolsonaro2"
colnames(M)[1]<-"Estimate"
colnames(M)[2]<-"SD"
M <- M %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Belief in Misinformation")
OneAtTime_belief_misinformation<- rbind(OneAtTime_belief_misinformation,M)
for (i in rownames(OneAtTime)){
OneAtTime[i,1:2]<-  One_At_A_Time("P28_covidmed_use",i,Data)
}
colnames(OneAtTime)[c(1,2)]<-c("Estimate","SD")
OneAtTime_P28_covidmed_use<- OneAtTime %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Covidmed Use")
model<- glm("P28_covidmed_use ~ P5_support_Bolsonaro", data = Data, family = binomial)
M<-data.frame(coef(summary(model))[3,1])
M[1,2]<-data.frame(coef(summary(model))[3,2])
rownames(M)[1]<-"P5_support_Bolsonaro2"
colnames(M)[1]<-"Estimate"
colnames(M)[2]<-"SD"
M <- M %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Covidmed Use")
OneAtTime_P28_covidmed_use<- rbind(OneAtTime_P28_covidmed_use,M)
for (i in rownames(OneAtTime)){
OneAtTime[i,1:2]<-  One_At_A_Time2("as.factor(P47_kitcovid)",i,Data)
}
colnames(OneAtTime)[c(1,2)]<-c("Estimate","SD")
OneAtTime_P47_kitcovid<- OneAtTime %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Kit Covid")
model<-polr("as.factor(P47_kitcovid) ~ P5_support_Bolsonaro", data = Data, Hess=TRUE)
M<-data.frame(coef(summary(model))[2,1])
M[1,2]<-data.frame(coef(summary(model))[2,2])
rownames(M)[1]<-"P5_support_Bolsonaro2"
colnames(M)[1]<-"Estimate"
colnames(M)[2]<-"SD"
M <- M %>%
tibble::rownames_to_column("term") %>%
mutate(Variable = "Kit Covid")
OneAtTime_P47_kitcovid<- rbind(OneAtTime_P47_kitcovid,M)
Models_MainDV2<-rbind(OneAtTimeP42_Stayhome,OneAtTime_belief_misinformation,
OneAtTime_P28_covidmed_use, OneAtTime_P47_kitcovid)
#When asked about beliefes and perceptions, bolsonaro support is hugely significant. Less so when asled about actions
Models_MainDV2<- Models_MainDV2 %>%
mutate(
term = recode(as.factor(term), P5_support_Bolsonaro2 = "Bolsonaro Loyalist", P5_support_Bolsonaro = "Bolsonaro Eventual Supporter", " P3_religion_Pentecostal" ="Pentecostal",
P31_trust_pol = "Trust Politicians",P41_People = "Informed by People",P37_earlytreat_Positive = "Positive View on Early Treatment",
interior = "Interior",treat_pref_worsening_Ordinal = "Drug Preference",P41_socmed = "Informed by Social Media",age_Group = "Age",
income = "Income", P1_race_NonWhite = "White",P41_tradmediaOnly = "Informed Only by Trade Media",P33_trust_ANVISA = "Trust ANVISA",
P2_educ =  "Education", sex = "Women",P17_covid_fear = "Covid Fear",P34_trust_press = "Trust Press",P32_trust_cientists = "Trust Scientists")
)
P.OneAtTime21 <- ggplot(Models_MainDV2, aes(x=term, y=exp(Estimate))) +
geom_errorbar(aes(ymin=exp(Estimate-2*SD), ymax=exp(Estimate+2*SD)), width=.1) +
geom_point(shape=19, size=2, alpha=0.7) +
geom_hline(yintercept=1, linetype="dashed",
size=1, alpha=0.5)+
theme_clean()+
ggtitle("Models for Main Misinformation Variables (Odds Ratio). One at a time") + theme(plot.title = element_text(hjust = 0.5, face = "plain")) +
xlab("") + ylab("")+
coord_flip(ylim = c(-1, 19))+
theme(legend.position = "none",
strip.text.y = element_blank(), panel.background = element_rect(fill="#00000000"))+
facet_grid(fct_reorder(term, Estimate, .desc = FALSE)~Variable, scale="free", space= "free")+
theme_bw()+
theme(strip.text.y = element_blank())
P.OneAtTime21
#Descriptive data on information
library(gtsummary)
Data %>%
select(P41_tradmediaOnly, P41_socmed, P41_People)%>%
tbl_summary()
#Press release
library(rlang)
PlotDVPropPress <- function(data, v){
data %>%
group_by_(v) %>%
dplyr::summarize(Misinformation = mean(belief_misinformation == 1, na.rm = T),
Kitcovid = mean(P47_kitcovid == 1, na.rm = T),
Stayhome = mean(P42_Stayhome == "Not stay home", na.rm = T)
) %>%
na.omit() %>%
gather(key = "Outcome", value = "Proportion", -v)
}
DVbyIncome <-PlotDVPropPress(Data, "income")
DVbyEducation <- PlotDVPropPress(Data, "P2_educ")
DVbyBolsonaro <- PlotDVPropPress(Data, "P5_support_Bolsonaro")
DVbyPentecostal <- PlotDVPropPress(Data, "P3_religion_Pentecostal")
DVbyIncome %>%
ggplot(aes(x = as.factor(income), y = Proportion))+
geom_col()+
facet_wrap(~Outcome)+
ggtitle("Misinformation by Income")+
labs(x="Income Level")+
coord_flip()+
theme_clean()+
scale_y_continuous(labels = scales::percent) +
scale_x_discrete(labels = c("One to two minimum wages","Two to three minimum wages",
"Three to five minimum wages","Five to 10 minimum wages",
"10 to 15 minimum wages","More than 15 minimum wages"))
DVbyEducation %>%
ggplot(aes(x = as.factor(P2_educ), y = Proportion))+
geom_col()+
facet_wrap(~Outcome)+
ggtitle("Misinformation by Education")+
labs(x="Education Level")+
coord_flip()+
theme_clean()+
scale_y_continuous(labels = scales::percent) +
scale_x_discrete(labels = c("Primary school or less",
"Secondary school", "Technical professional degree",
"University degree", "Postgraduate"))
write.csv(DVbyEducation,'C:/Users/ntite/Dropbox/Covid & Misinformation in BR/DVbyEducation.csv')
write.csv(DVbyBolsonaro,'C:/Users/ntite/Dropbox/Covid & Misinformation in BR/DVbyBolsonaro.csv')
write.csv(DVbyIncome,'C:/Users/ntite/Dropbox/Covid & Misinformation in BR/DVbyIncome.csv')
write.csv(DVbyPentecostal,'C:/Users/ntite/Dropbox/Covid & Misinformation in BR/DVbyPentecostal.csv')
DVbyPentecostal %>%
ggplot(aes(x = as.factor(P3_religion_Pentecostal), y = Proportion))+
geom_col()+
facet_wrap(~Outcome)+
ggtitle("Misinformation by Religion")+
labs(x="Religion")+
coord_flip()+
theme_clean()+
scale_y_continuous(labels = scales::percent) +
scale_x_discrete(labels = c("Not Pentecostal", "Pentecostal"))
DVbyBolsonaro %>%
ggplot(aes(x = as.factor(P5_support_Bolsonaro), y = Proportion))+
geom_col()+
facet_wrap(~Outcome)+
ggtitle("Misinformation by Bolsonaro Support")+
labs(x="Bolsonaro Support")+
coord_flip()+
theme_clean()+
scale_y_continuous(labels = scales::percent)
